home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
Storage.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-06-11
|
2KB
|
67 lines
#ifndef Storage_First
#ifdef __GNUG__
//pragma once
#pragma interface
#endif
#define Storage_First
#include "Types.h"
typedef void (*FreeHookFun)(void *, void *addr, size_t);
//---- Pools of fixed size storage allocators -----------------------
class Storage {
char dummy;
public:
static void *Alloc(size_t sz);
static void *Alloc(size_t sz, const char *file, int line);
static void Free(void *vp);
static void *ChunkAlloc(size_t sz);
static void ChunkFree(void *vp);
static void *ObjectChunkAlloc(size_t sz);
static void ObjectChunkFree(void *vp);
static void *ObjectAlloc(size_t sz);
static void *ObjectAlloc(size_t sz, const char *file, int line);
static void ObjectFree(void *vp);
static void *ReAlloc(void *vp, size_t sz);
static void Statistics();
static void SetFreeHook(FreeHookFun, void *data);
static void FreeAll();
static void EnableStatistics(int size= -1, int ix= -1);
};
extern "C" void *Realloc(void*, size_t);
inline void *operator new(size_t sz, const char *file, int line)
{ return Storage::Alloc(sz, file, line); }
#define dnew new(__FILE__, __LINE__)
//---- misc ---------------------------------------------------------
#if defined(sun) || defined(sony)
# if defined(sparc) && !defined(alloca)
# define alloca(x) __builtin_alloca(x)
# endif
# if !defined(sony) && !defined(__GNUG__)
extern "C" void *alloca(size_t);
# endif
# define Alloca(x) alloca(x)
# define Freea(x)
#else
# define Alloca(x) ((void*) (new char[x]))
# define Freea(x) delete (x)
#endif
#endif